package com.bcn.login_mybatisplus_demo.storage.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.bcn.login_mybatisplus_demo.interceptor.AuthStorage;
import com.bcn.login_mybatisplus_demo.item.domain.TAppItem;
import com.bcn.login_mybatisplus_demo.storage.domain.TAppStorage;
import com.bcn.login_mybatisplus_demo.storage.mapper.TAppStorageMapper;
import com.bcn.login_mybatisplus_demo.storage.service.ITAppStorageService;
import com.bcn.login_mybatisplus_demo.util.Convert;
import com.bcn.login_mybatisplus_demo.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 收纳区域Service业务层处理
 * 
 * @author administrator
 * @date 2025-03-13
 */
@Service
public class TAppStorageServiceImpl implements ITAppStorageService
{
    @Autowired
    private TAppStorageMapper tAppStorageMapper;

    /**
     * 查询收纳区域
     * 
     * @param storageId 收纳区域ID
     * @return 收纳区域
     */
    @Override
    public TAppStorage selectTAppStorageById(Long storageId)
    {
        return tAppStorageMapper.selectTAppStorageById(storageId);
    }

    /**
     * 查询收纳区域列表
     * 
     * @param tAppStorage 收纳区域
     * @return 收纳区域
     */
    @Override
    public List<TAppStorage> selectTAppStorageList(TAppStorage tAppStorage)
    {
        tAppStorage.setUserId(AuthStorage.getUser().getId());
        return tAppStorageMapper.selectTAppStorageList(tAppStorage);
    }

    /**
     * 新增收纳区域
     * 
     * @param tAppStorage 收纳区域
     * @return 结果
     */
    @Override
    public int insertTAppStorage(TAppStorage tAppStorage)
    {
        tAppStorage.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        tAppStorage.setUserId(AuthStorage.getUser().getId());
        tAppStorage.setIsDefault(0);
        return tAppStorageMapper.insertTAppStorage(tAppStorage);
    }

    /**
     * 修改收纳区域
     * 
     * @param tAppStorage 收纳区域
     * @return 结果
     */
    @Override
    public int updateTAppStorage(TAppStorage tAppStorage)
    {
        return tAppStorageMapper.updateTAppStorage(tAppStorage);
    }

    /**
     * 删除收纳区域对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteTAppStorageByIds(String ids)
    {
        return tAppStorageMapper.deleteTAppStorageByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除收纳区域信息
     * 
     * @param storageId 收纳区域ID
     * @return 结果
     */
    @Override
    public int deleteTAppStorageById(Long storageId)
    {
        return tAppStorageMapper.deleteTAppStorageById(storageId);
    }
}
